package com.cheer.ba.view.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.cheer.ba.R;
import com.cheer.ba.cache.preference.Session;
import com.cheer.ba.model.CommentModel;
import com.cheer.ba.utils.ImageUtils;
import com.cheer.ba.utils.Protect;
import com.cheer.ba.utils.StringUtils;

import java.util.List;

/**
 * 回复adpter
 * Created by Hq on 2017/7/4.
 */
public class ReplyAdp extends BaseQuickAdapter<CommentModel, BaseViewHolder> {

    public ReplyAdp(@LayoutRes int layoutResId, @Nullable List<CommentModel> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CommentModel item) {
        if (null != item) {
            ImageUtils.showCircleImg(mContext, Protect.setPic(item.custImg), R.drawable.ic_user_head, R.drawable.ic_user_head, (ImageView) helper.getView(R.id.id_reply_head_img));
            helper.setText(R.id.id_reply_name_txt, item.custNname);
            helper.setText(R.id.id_reply_content_txt, item.context);
            helper.setText(R.id.id_reply_time_txt, StringUtils.getDetailStr(item.releaseDate));
            if (TextUtils.equals(Session.getUserId(), item.custId)) {
                helper.getView(R.id.id_del_reply_txt).setVisibility(View.VISIBLE);
                helper.addOnClickListener(R.id.id_del_reply_txt);
            } else {
                helper.getView(R.id.id_del_reply_txt).setVisibility(View.GONE);
            }
        }
    }
}
